﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <title>打印</title>
    <link href="~/hiprint/css/hiprint.css" rel="stylesheet" />
    <link href="~/hiprint/css/print-lock.css" rel="stylesheet" />

    <script src="https://cdn.jsdeliver.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script src="~/hiprint/polyfill.min.js"></script>
    <script src="~/hiprint/hiprint.bundle.js"></script>
    <script src="~/hiprint/plugins/jsbarcode.all.min.js"></script>
    <script src="~/hiprint/plugins/qrcode.js"></script>
    <script src="~/hiprint/plugins/jquery.hiwprint.js"></script>
</head>
<body>
    @* <button class="layui-btn layui-btn-primary layui-border-blue" onclick="PrintThis()" style="margin-left:330px;margin-top:100px">打印</button>
    <div id="templateDesignDiv" style="margin-left:auto;margin-right:auto;width:800px;margin-top:-40px"></div> *@
    <script>
        $(function () {
            print();
            PrintThis();
        })
        hiprint.init();
        var hiprintTemplate;
        var obj = { "panels": [{ "index": 0, "paperType": "A4", "height": 297, "width": 210, "paperHeader": 43.5, "paperFooter": 801, "printElements": [{ "options": { "left": 189, "top": 64.5, "height": 27, "width": 172.5, "title": "入库单信息打印", "fontSize": 21, "color": "#eb1291" }, "printElementType": { "type": "text" } }, { "options": { "left": 7.5, "top": 156, "height": 61.5, "width": 550, "columns": [[{ "title": "入库单编号", "width": 117.12148076923079, "colspan": 1, "rowspan": 1, "checked": true }, { "title": "入库日期", "width": 105.35205917159766, "colspan": 1, "rowspan": 1, "checked": true }, { "title": "入库类型编号", "width": 121.62032544378688, "colspan": 1, "rowspan": 1, "checked": true }, { "title": "备注", "width": 205.90613461538464, "colspan": 1, "rowspan": 1, "checked": true }]] }, "printElementType": { "title": "表格", "type": "tableCustom" } }], "paperNumberLeft": 565, "paperNumberTop": 819 }] }

        console.log(obj);
        hiprintTemplate = new hiprint.PrintTemplate({
            template: obj,
        });
        hiprintTemplate.design('#templateDesignDiv', { grid: true });
        function print() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo);
            $.ajax({
                // location.href = '@ViewBag.Durian' + '/api/Assembly/ExportFarrowingsExcel';
                url: '@ViewBag.GlennQuigmrire' + '/api/InboundOrder/PrintInboundOrder',
                data: JSON.stringify({ inboundOrderNumber: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.objects != null) {
                        let html = hiprintTemplate.getHtml(res.objects);
                        $("#templateDesignDiv").html(html);
                    }
                }
            })
            $("#templateDesignDiv").empty();
        }
        function PrintThis() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo);
            $.ajax({
                // location.href = '@ViewBag.Durian' + '/api/Assembly/ExportFarrowingsExcel';
                url: '@ViewBag.GlennQuigmrire' + '/api/InboundOrder/PrintInboundOrder',
                data: JSON.stringify({ inboundOrderNumber: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.data != null) {
                        hiprintTemplate.print(res.data);
                    }
                }
            })
        }
    </script>
</body>
</html>